var token=wx.getStorageSync('token')
module.exports={
  getSysRelation: function () {
    wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": "/api/relation/sysRelation",
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": commonAPI.getTokenFromLocal()
      },
      "method": "GET",
      "data": {}
    }).then((res)=>{
      return res
    })
  
  },
  addRelation: function (relation) {
    //  var relation={
    //   "relationId": "",
    //   "initiatorId": "",
    //   "receiverId": reiceiverId,
    //   "relationTypeId": ,
    //   "relationStatus": ""
    //  }   
   var res=  wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": "/api/relation/",
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "POST",
      "data": relation
    }).then((res)=>{
       return res
    })
    return res

  },
  deleteRelation:async function (relationId) {
   var res= await wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": '/api/relation/'+relationId,
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "DELETE",
      "data": ""
    }).then((res)=>{return res})
    return res
  },
  updateRelation:async function (relation) {
    // var relation={
    //   "relationId": relationId,
    //   "initiatorId": "",
    //   "receiverId": receiverId,
    //   "relationTypeId": "",
    //   "relationStatus": ""
    // }
    var res= await wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": "/api/relation/",
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "PUT",
      "data": relation
    }).then((res)=>{
      // console.log(res)
      return res
    })
    return res
    
  
  },
  getRelation:async function () {
   var token= wx.getStorageSync('token')

  var path='/api/relation/1'
   var res= await wx.cloud.callContainer({
      "config": {
        "env": "prod-3gfrot0nb41198bc"
      },
      "path": path,
      "header": {
        "X-WX-SERVICE": "springboot-zd5r",
        "content-type": "application/json",
        "token": token
      },
      "method": "GET",
      "data": {}
    }).then((res)=>{
      return res
    })
    console.log(res)
    return res
  }

  

}